package com.cvte.shop.service.impl;

import com.cvte.csb.core.interfaces.vo.RestResponse;
import com.cvte.csb.web.rest.ResponseFactory;
import com.cvte.shop.entity.UniversalMethodConfig;
import com.cvte.shop.entity.dto.MethodDTO;
import com.cvte.shop.service.UniversalMethodConfigService;
import com.cvte.shop.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.cvte.csb.jdbc.mybatis.biz.BaseBiz;
import com.cvte.shop.mapper.UniversalMethodConfigMapper;
import org.springframework.transaction.annotation.Transactional;

/**
 * 服务实现类
 *
 * @author inv
 * @since 2020-08-04
 */
@Service
@Transactional
public class UniversalMethodConfigServiceImpl extends BaseBiz<UniversalMethodConfigMapper, UniversalMethodConfig> implements UniversalMethodConfigService {

    @Autowired
    private UniversalMethodConfigMapper universalMethodConfigMapper;

    @Override
    public RestResponse addMethodConfig(MethodDTO methodDTO) {
        UniversalMethodConfig methodConfig = new UniversalMethodConfig(methodDTO);
        methodConfig.setMethodId(UUIDUtil.getUUID());
        methodConfig.setRequestType(methodConfig.getRequestType().toUpperCase());
        universalMethodConfigMapper.insert(methodConfig);
        return ResponseFactory.getOkResponse(methodConfig);
    }
}
